import 'package:FineArt/constants.dart';
import 'package:FineArt/core/api/resource_api.dart';
import 'package:FineArt/utils/size_config.dart';
import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';

/// 列表项
class ListItemVideoPlay extends StatelessWidget {
  // 文字
  final String url;
  final String title;
  final ResourceInfoVideo detail;

  //点击事件
  final GestureTapCallback onTap;
  final double width;
  final double height;
  final BoxFit boxFit;

  // 构造函数
  const ListItemVideoPlay(
      {Key key,
      this.url,
      this.title = '静物组合操作视频(第二集)',
      this.detail,
      this.onTap,
      this.width,
      this.height = 0,
      this.boxFit = BoxFit.cover})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    String serious = detail != null && detail.seriesname.length > 0 && detail.seriesname != "undefined"
        ? "(" + detail.seriesname + ")"
        : "";
    return InkWell(
        onTap: onTap,
        child: Padding(
            padding: EdgeInsets.all(1),
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Container(
                  color: Colors.black,
                  child: Stack(
                    alignment: Alignment.center,
                    children: [
                      Image(
                          fit: boxFit,
                          width: width,
                          height: height,
                          image: CachedNetworkImageProvider(
                            url,
                          )),
                      Icon(
                        Icons.play_circle_outline_outlined,
                        size: 20,
                        color: Colors.white,
                      ),
                    ],
                  ),
                  // Icon(
                  //   Icons.play_circle_outline_outlined,
                  //   size: 20,
                  //   color: Colors.white,
                  // ),
                  height: getPortraitSHeight(85),
                  width: getPortraitSWidth(150),
                ),
                SizedBox(
                  width: 20,
                ),
                Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Container(
                      width: getPortraitSWidth(190),
                      child: Text(
                        title + serious,
                        style:
                            TextStyle(fontSize: setSp(13), color: text_black),
                      ),
                    ),
                    SizedBox(
                      height: 20,
                    ),
                    Text(
                      detail != null ? "主讲:${detail.author} " : "",
                      style:
                          TextStyle(fontSize: setSp(11), color: class_tab_gray),
                    )
                  ],
                )
              ],
            )));
  }
}
